/**
 * GcmServer
 * GcmException.java
 * 
 * Copyright 2013 Teachizen
 * Written by cloudstick
 *	2013. 8. 5. first written.
 *
 * note:
 */
package com.bnsworks.server.push.gcm;

/**
 * @author cloudstick
 *
 */
@SuppressWarnings("serial")
public class GcmException extends RuntimeException {

	private int status;
	private String description;
	
	public GcmException(String message) {
		super(message);
	}
	
	public GcmException(String message, Throwable e) {
		super(message, e);
	}
	
	public GcmException(int status) {
	    this(status, (String)null);
	}

	public GcmException(int status, String description) {
	    this(getMessage(status, description));
	    this.status = status;
	    this.description = description;
	}

	private static String getMessage(int status, String description) {
	    StringBuilder base = new StringBuilder("HTTP Status Code: ").append(status);
	    if (description != null) {
	    	base.append("(").append(description).append(")");
	    }
	    return base.toString();
	}

	/**
	 * Gets the HTTP Status Code.
	 */
	 public int getHttpStatusCode() {
		 return status;
	 }

	 /**
	  * Gets the error description.
	  */
	 public String getDescription() {
		 return description;
	 }
}
